package com.itheima.dubbo.service;

import com.itheima.dubbo.UserInterface;
import com.itheima.pojo.User;
import org.apache.dubbo.config.annotation.DubboService;
import org.apache.dubbo.config.annotation.Method;
import org.apache.dubbo.rpc.RpcContext;

//@DubboService(timeout = 1000)
//@DubboService(methods = {@Method(name="hello",timeout = 3000)})
@DubboService(version = "1.0.1",retries=0,loadbalance = "roundrobin", weight = 10)
public class UserInterfaceImpl implements UserInterface {
    @Override
    public String hello(String username) {
        System.out.println("UserServiceImpl......");

        String jwt = RpcContext.getContext().getAttachment("jwt");
        System.out.println(jwt);
        try {
            Thread.sleep(2000L);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        return "Hello Dubbo username: " + username;
    }

    @Override
    public User findUser(User userVo) {
        User user = new User();
        user.setName(userVo.getName());
        return user;
    }
}
